<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			传统JS:<input type="text" onkeydown="showKeyCode()" />
			<hr />
			<!-- $ 代表一个对象 -->
			Vue:<input type="text" v-on:keydown="fun($event)" />
		</div>
		<script type="text/javascript">
			function showKeyCode() {
				var keycode = event.keyCode;
				if (keycode == 13) {
					alert("你按的回车");
				}
				if (keycode > 48 && keycode < 57) {
					// 不让按键起作用
					event.preventDefault();
					// alert(keycode);
				}
			}

			var vm = new Vue({
				el: '#app',
				data: {

				},
				methods: {
					fun(event) {
						var keyCode = event.keyCode;
						if (keyCode == 13) {
							alert("你按的回车");
						}
						if (keyCode > 48 && keyCode < 57) {
							event.preventDefault();
						}
					}
				}
			});
		</script>
	</body>
</html>
